<template>
  <div>
    <div v-if="remindOne">
      <h1 style="text-align: center">{{remindOne.remark}}</h1>
      <div style="text-align: center; font-size: 100px; font-weight: bold; padding: 10px;">{{getDay()}} <span style="font-size: 26px">天</span></div>
    </div>
    <div v-if="!remindOne">
      <h1 style="text-align: center">当前没有活动</h1>
    </div>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        remindList:'',
        remindOne:''
      }
    },
    mounted() {
      this.getRemind()
    },
    methods: {
      getRemind() {
        this.$http({
          url: this.$http.adornUrl('/app/reminder'),
          method: 'get'
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.remindList = data.data
            if(this.remindList.length>0){
              this.remindOne = this.remindList[0];
            }else{
              this.remindOne = '';
            }
          }
        })
      },
      getDay(){
        if(this.remindOne){
          let str = this.remindOne.endDate.replace(/-/g, '/');
          let endDate = new Date(str);
          return Math.ceil(this.getDays(endDate, new Date()));
        }
        return 0
      },
      getDays(date1,date2){
        return (date1.getTime()-date2.getTime())/(3600*24*1000);
      }
    }
  }
</script>

<style scoped>
  .rotateBg{
    width: 600px;
    height: 600px;
    /* background: url(~@/assets/img/pan.png) no-repeat; */
    background-size: 600px;
  }
</style>

